#pragma once
#include <QMap>
#include <QObject>
#include <QHostAddress>

#include "ManagerBase.h"
#include "../user/AbstractUser.h"

class UserManager : public QObject, public ManagerBase<UserManager> {
    Q_OBJECT
public:
    AbstractUser* newUser(quint16 id, const QHostAddress& addr, quint16 port);
    AbstractUser* findUser(quint16 id) { return users.value(id, nullptr); }

    void removeUser(quint16 id);
    void removeUser(const QHostAddress& addr, quint16 port);

    void UserBroadcast(quint16 id, const QByteArray& msg);

private:
    QMap<quint16, AbstractUser*> users; // key = userId
};
